function formatTime(value, hourShow = true, full = false) {
  function pad(value, length = 2) {
    return String(value).padStart(length, '0');
  }

  const time = new Date(value);
  const year = String(time.getFullYear());
  const month = pad(time.getMonth() + 1);
  const day = pad(time.getDate());
  const dateStr = [ year, month, day ].join('-');
  if(!hourShow) return dateStr;

  const hours = pad(time.getHours());
  const minutes = pad(time.getMinutes());
  const seconds = pad(time.getSeconds());

  const miliseconds = pad(time.getMilliseconds(), 3);
  return `${dateStr} ${[ hours, minutes, seconds ].join(':')}${full ? miliseconds : ''}`;
}

module.exports = formatTime;